//
//  POSAddView.m
//  NewPro
//
//  Created by 何荧红 on 2019/3/20.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "POSAddView.h"

@implementation POSAddView

-(instancetype)init{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(SCREEN_WIDTH - 140, 0, 135, 95);
        [self CreateWithView];
    }
    return self;
}
- (void)CreateWithView{
    UIImageView *bgimage = [[UIImageView alloc]init];
    bgimage.image = [UIImage imageNamed:@"划拨BG"];
    [self addSubview:bgimage];
    [bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    UIView *addline = [[UIView alloc]init];
    addline.backgroundColor = [UIColor colorWithHexString:@"666666"];
    [self addSubview:addline];
    [addline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(44);
        make.centerX.equalTo(self.mas_centerX);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(95);
    }];
    for (NSInteger i = 0; i < 2; i++) {
        UIButton *chocont = [[UIButton alloc]init];
        chocont.tag = 2024 + i;
        chocont.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
        [chocont setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [chocont addTarget:self action:@selector(chooseViewClik:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:chocont];
        [chocont mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX);
            if (i == 0){
                make.top.equalTo(self.mas_top).offset(4);
            }
            if (i == 1) {
                make.top.equalTo(self.mas_top).offset(45);
            }
            make.height.mas_equalTo(40);
            make.width.mas_equalTo(126);
        }];
        if (i == 0) {
            [chocont setTitle:@"划拨规则" forState:UIControlStateNormal];
        }
        if (i == 1) {
            [chocont setTitle:@"自备机器入网" forState:UIControlStateNormal];
        }
    }
}
- (void)chooseViewClik:(UIButton *)button{
    if (self.POSAddBlock) self.POSAddBlock(button.tag - 2024);
}
@end
